import {Vector4} from "../math/Vector4";
import {OutPutBuffer} from "./OutPutBuffer";

export class FrameBuffer extends OutPutBuffer{

    constructor(width: number, height: number, yFlip: boolean = false) {
        super(width, height, 4, yFlip);
    }

    drawPoint(x: number, y: number, color: Vector4) {
        this.setPositionData(x, y, color.data);
    }

    setClearColor(color: Vector4) {
        this.setBackground(color.data);
    }

    protected elementFillToImage(dataOffset: number, imageOffset: number) {
        this.imageData.data[imageOffset + 0] = this.data[dataOffset + 0] * 255;
        this.imageData.data[imageOffset + 1] = this.data[dataOffset + 1] * 255;
        this.imageData.data[imageOffset + 2] = this.data[dataOffset + 2] * 255;
        this.imageData.data[imageOffset + 3] = this.data[dataOffset + 3] * 255;
    }

}